local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script,script.Parent.AFKBase);

function M.new(...)
	return M(...);
end;

function M.ctor(self,...)--构造函数
	M.super.ctor(self,...);
end;
function M.dtor(self)--析构函数
    M.super.dtor(self);
end;


function M.SubInit(self)
    --监听gamepass购买情况
    if self.IsClient then
        self.player.UserDataEvent:Connect(function(data)
            if data["gamePass"] then
                self:upd()
            end
        end)
    else
        self.player.UserDataEvent:Connect(function(key)
            if key=="gamePass" then
                self:upd()
            end
        end)
    end
    self:upd()
end


function M.upd(self)
    local gamepassData = self.DataStore:GetData("gamePass")
    if gamepassData["VIP"] and (not self.isDone) then
        self.isDone=true
        self.UpdateEvent:Action()
        return
    end
end

--当玩家进入然后退出afk区域，移除效果
function M.RemoveUse(self)
    if not self.RngDataCtrl then
        self.RngDataCtrl=self.player:GetComponent(_G.CommonOHOH.load.Common_RngDataLayer())
    end

    self.RngDataCtrl:AddLucky(-self.value)
end

--当玩家进入afk区域，添加效果
function M.Use(self)
    if not self.RngDataCtrl then
        self.RngDataCtrl=self.player:GetComponent(_G.CommonOHOH.load.Common_RngDataLayer())
    end

    self.RngDataCtrl:AddLucky(self.value)
end


return M